package org.stone.project;

import org.stone.project.sub.TempSub;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;

import java.time.Duration;
import java.util.concurrent.TimeUnit;

public class ReactorDemo {
    public static void main(String[] args) throws InterruptedException {
        System.out.println(Thread.currentThread().getName());


        TempSub tempSub = new TempSub();

        Duration duration = Duration.ofNanos(1);
        Flux.just("1", "2", "3", "4", "5", "6", "7", "8", "9")
                .delayElements(duration)
                .map(e -> {
                    System.out.println(Thread.currentThread().getName());
                    System.out.println("当前线程" + Thread.currentThread().getName());
                    return e;
                })
                .subscribe(tempSub);

        Thread.currentThread().join();
    }
}
